package com.choco.jsondb.example;

import com.alibaba.fastjson.JSON;
import com.choco.jsondb.JSONDB;
import com.choco.jsondb.editor.Editor;

/*
Output:

{"address":"China","name":"Steven"}
{"address":"China","name":"Jobs"}
 */
public class KVExample {
    public static void main(String[] args){
        JSONDB jsondb = new JSONDB.Builder().folder("jsondb").connect();
        Editor editor = jsondb.edit();
        editor.put("me", new Person("Steven", "China"));
        editor.put("myself", JSON.toJSONString(new Person("Jobs", "China")));
        editor.commit();

        System.out.println(jsondb.get("me"));
        System.out.println(jsondb.get("myself"));
    }
}
